Skip to content

GODRIVER-3892 Move count to the mongo package.#2483

Merged
prestonvasquez merged 3 commits into
mongodb:masterfrom
matthewdale:godriver3892-move-count
Jul 17, 2026
Merged

GODRIVER-3892 Move count to the mongo package.#2483
prestonvasquez merged 3 commits into
mongodb:masterfrom
matthewdale:godriver3892-move-count

Conversation

@matthewdale

@matthewdale matthewdale commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

GODRIVER-3892

Summary

Move the count operation logic from the x/mongo/driver/operation package to the mongo package, removing the unnecessary chainable setters. Don't export the moved types.

Background & Motivation

Part of a larger effort to reduce unnecessary code by removing the x/mongo/driver/operation package.

@mongodb-drivers-pr-bot

Copy link
Copy Markdown
Contributor

API Change Report

./v2/x/mongo/driver/operation

incompatible changes

Count: removed
CountResult: removed
NewCount: removed

@mongodb-drivers-pr-bot

mongodb-drivers-pr-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

🧪 Performance Results

Commit SHA: 554f9c4

The following benchmark tests for version 6a59dbf8a8cda90007976081 had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkBSONFlatDocumentDecoding ops_per_second_min -51.1394 1093.8681 Avg: 2238.7515
Med: 2372.0065
Stdev: 449.5253
0.8013 -2.5469
BenchmarkSingleRunCommand allocated_bytes_per_op 0.2704 12238.0000 Avg: 12205.0000
Med: 12209.0000
Stdev: 10.5830
0.8653 3.1182

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@matthewdale matthewdale added review-priority-low Low Priority PR for Review: within 3 business days ignore-for-release labels Jul 11, 2026
@matthewdale
matthewdale force-pushed the godriver3892-move-count branch from 6e1c991 to 969385a Compare July 14, 2026 03:10
@matthewdale matthewdale added review-priority-normal Medium Priority PR for Review: within 1 business day and removed review-priority-low Low Priority PR for Review: within 3 business days labels Jul 14, 2026
@matthewdale
matthewdale marked this pull request as ready for review July 14, 2026 04:40
@matthewdale
matthewdale requested a review from a team as a code owner July 14, 2026 04:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves the internal “count” operation implementation out of x/mongo/driver/operation and into the mongo package, simplifying EstimatedDocumentCount by removing the chainable setter style and keeping the moved types unexported.

Changes:

  • Removed the legacy Count operation implementation from x/mongo/driver/operation.
  • Added an unexported countOp implementation in mongo/ to execute the count command and parse results.
  • Updated Collection.EstimatedDocumentCount to construct and run countOp directly, setting comment/rawData fields without setters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
x/mongo/driver/operation/count.go Removes the previous Count operation implementation from the x/ operations layer.
mongo/op_count.go Adds the new unexported countOp + result parsing logic in the mongo package.
mongo/collection.go Switches EstimatedDocumentCount from operation.NewCount() to the new countOp struct literal wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mongo/op_count.go Outdated
Comment thread mongo/op_count.go
Comment thread mongo/op_count.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread mongo/op_count.go Outdated
@prestonvasquez
prestonvasquez merged commit 4bed2c3 into mongodb:master Jul 17, 2026
31 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants